package com.cjhedu.web.controller;

import com.cjhedu.web.service.FileService;
import com.cjhedu.web.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author 陈佳豪
 * @version 1.0
 * 文件上传
 */
@RestController
@RequestMapping("/testload")
public class MyUploadTestController {
    @Autowired
    private FileService fileService;

    @PostMapping("/upload")
    public Result upload(String name, Integer age, MultipartFile image) throws IOException {
        System.out.println("name=" + name);
        System.out.println("age=" + age);
        String s = fileService.saveFile(image);
        return Result.success(s);
    }
}
